<?php
class newsModel extends CModel{
    protected $table    = 'news';
    protected $prikey   = 'id';
    protected $_name    = 'news';
    protected $alias    = 'n';
    protected $_relation = array(
        // 一篇文章属于一个分类
        'belongs_to_category' => array(
            'model'             => 'category',
            'type'              => BELONGS_TO,
            'foreign_key'       => 'cid',
            'reverse'           => 'has_news',
            'ext_limit'         => array('hidden' => '0'),
        ),
    );
    
    public function main()
    {
        
    }
    
    public function get_list()
    {
        $findargs = array(
            'fields'=>array('this.id,this.subject,category.name'),
            'join'  =>'belongs_to_category',
            'where' =>'1',
            'order' =>'id'
            );
        return $this->find($findargs);
    }
}
?>